<?php
    /*
      Klenwell Wikka Template Footer

    */

    # INIT
    global $tstart;
    $patch_level = ($this->GetWikkaPatchLevel() != '0')
        ? sprintf('-p%s', $this->GetWikkaPatchLevel())
        : '';
    $gaf = <<<XHTML
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "%s";
urchinTracker();
</script>
XHTML;



    # DYNAMIC SETTINGS
    if ( ! empty($this->config['ga_code']) ) {
        $ga_block = sprintf($gaf, $this->config['ga_code']);
    }
    else {
        $ga_block = '';
    }

    if ( $this->IsAdmin() ) {
        $powered_by = sprintf('WikkaWiki %s%s', $this->GetWakkaVersion(), $patch_level);
    }
    else {
        $powered_by = 'WikkaWiki';
    }

    if ( $this->GetConfigValue('sql_debugging') )
    {
        $sql_configf = <<<XHTML

<div class="smallprint" style="background:#fff; padding:1em;">
    <h4>Query log:</h4>
    <pre style="background:#eee; padding:4px; border:1px solid #ccc;">
    %s
    </pre>
</div>

XHTML;
        $log_dump = print_r($this->queryLog, 1);
        $sql_config_block = sprintf($sql_configf, $log_dump);
    }
    else {
        $sql_config_block = '';
    }

    $page_load_time = sprintf('<!-- %s -->',
                              sprintf(PAGE_GENERATION_TIME,
                                      $this->microTimeDiff($tstart)));



    # TEMPLATES
    $footerf = <<<XHTML
<div id="footer">
    %s
</div>
XHTML;

    $smallprintf = <<<XHTML
<div id="smallprint">
    %s &bull; %s &bull; %s
</div>
XHTML;

    $closetagf = <<<XHTML
    </div>
    <!-- end page wrapper -->
$sql_config_block
$page_load_time
$ga_block
</body>
</html>
XHTML;



    # OUTPUT
    printf($footerf, $this->MakeMenu('options_menu'));
    printf($smallprintf,
           $this->Link('http://validator.w3.org/check/referer', '',
                       'Valid XHTML 1.0 Transitional'),
           $this->Link('http://jigsaw.w3.org/css-validator/check/referer', '',
                       'Valid CSS'),
           $this->Link('http://wikkawiki.org/', '', $powered_by) );
    printf($closetagf);
